<!DOCTYPE html>
<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/include.jsp"%>
<html>
<head>
<META http-equiv="Content-Type" content="text/html;charset=UTF-8">

<title><spring:message code="title" /></title>
<meta name="description" content="" />

<link rel="stylesheet" type="text/css" href="../css/config.css" />
<link rel="stylesheet" type="text/css"
	href="../css/imgareaselect-default.css" />

<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/jquery.validate.js"></script>
<script type="text/javascript" src="../js/jquery.validate.others.js"></script>
<!-- 
<script type="text/javascript" src="../scripts/jquery.min.js"></script>  -->
<script type="text/javascript"
	src="../scripts/jquery.imgareaselect.pack.js"></script>

<script type="text/javascript"> 
$(function(){
    $('#form').validate({
        rules :{
        	k : {
            	required	: true,
            	number 		: true,
            	min 		: 0,
            	max 		: 255
            },
            nameOutFile : {
            	required 	: true
            },
            mode : {
            	required 	: true
            }
        },
        messages : {
        	k : {
            	required 	: "<spring:message code="errorRequired" />",
            	number 		: "<spring:message code="errorNumber" 	/>",
            	min 		: "<spring:message code="errorMin" arguments="0" 	/>",
            	max 		: "<spring:message code="errorMin" arguments="255" 	/>"
            },
            nameOutFile : {
            	required 	: "<spring:message code="errorRequired" />"
            },
            mode : {
            	required 	: "<spring:message code="errorRequired" />"
            }
        },
        submitHandler: function(form){
            form.submit();
        }
    }); 
});

</script>

</head>
<body>
<%! 
	String checked_i="";
	String checked_c="";
%>
<%
					if (session.getAttribute("mode") != null
								&& (session.getAttribute("mode")).equals("-c")) {
					checked_i="";
					checked_c="checked";
					}else{
						checked_i="checked";
						checked_c="";
					}
%>
	<jsp:include page="/WEB-INF/views/menu.jsp" />
	<form:form id="form" name="form" method="post">
		<input type="hidden" name="k1" value="" />
		<input type="hidden" name="nameOutFile1" value="" />
		<table>
			<tr>
				<fieldset>
					<legend>
						<spring:message code="menu.tools.kmeans" />
					</legend>
					<div>
						<spring:message code="k" />
						<input path="k" name="k" size="3" maxlength="3" value="<%=session.getAttribute("k")%>" />
						<errors path="k" cssClass="error" />
					</div>
					<div>
						<label for="nameOutFile" path="nameOutFile"><spring:message code="nameOutFile"/></label>
						<input path="nameOutFile"  name="nameOutFile" value="<%=session.getAttribute("nameOutFile")%>"/>
						<errors path="nameOutFile" cssClass="error" />
					</div>
					<div> 
						<input type="radio" name="mode" value="-i" <%=checked_i%> >Iterativo<br>
						<input type="radio" name="mode" value="-c" <%=checked_c%> >Continuo 
					</div>
					<div>
						<br> <input type="submit"
							value="<spring:message code="menu.tools.classify"/>"
							id="classifyKmeans" name="classifyKmeans" /> <br>
						<br>
					</div>
				</fieldset>
			</tr>
			<tr>
				<br>
				<br>
				<%
					if (session.getAttribute("uploadFile") != null
								&& !(session.getAttribute("uploadFile")).equals("")) {
				%>
				<div style="height: 600px; width: 600px; overflow: scroll;">
					 
					<img id="photo" src="<%=session.getAttribute("uploadFile")%>"
						alt="Imagen a clasificar <%=session.getAttribute("uploadFile")%> " />
				</div>
				<%
					}
				%>
			</tr>
		</table>
	</form:form>
</body>
</html>